<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑页面</title>
    <link rel="stylesheet" href="${request.contextPath}/plugins/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/jquery-confirm/jquery-confirm.min.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/animate.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/style.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/common.css">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-md-12">
            <div class="ibox">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="druginfoEditForm">
                        <input type="hidden" value="${(entity.id)}" name="id"/>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">药品类型：</label>
                            <div class="col-sm-9">
                                <select id="typeId" name="typeId" class="form-control select2" style="width: 100%;" required>
                                    <option value="">请选择药品类型</option>
                                    <#list drugTypeList as drugType>
                                    <option value="${(drugType.id)!}" ${(entity.typeId?? && drugType.id==entity.typeId)?string('selected="selected"','')}>
                                        ${(drugType.name)!}
                                    </option>
                                    </#list>
                                </select>
                                <input value="${(entity.typeName)!}" type="hidden" id="typeName" name="typeName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">药品名称：</label>
                            <div class="col-sm-9">
                                <input value="${(entity.name)!}" type="text" id="name" name="name" class="form-control"
                                       placeholder="请输入药品名称" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">通用名称：</label>
                            <div class="col-sm-9">
                                <input value="${(entity.commonName)!}" type="text" id="commonName" name="commonName"
                                       class="form-control" placeholder="请输入通用名称" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">药品等级：</label>
                            <div class="col-sm-9">
                                <select id="fdaId" name="fdaId" class="form-control select2" style="width: 100%;" required>
                                    <option value="">请选择药品等级</option>
                                    <#list drugFdaList as drugFda>
                                    <option value="${(drugFda.id)!}" ${(entity.fdaId?? && drugFda.id==entity.fdaId)?string('selected="selected"','')}>
                                        ${(drugFda.name)!}
                                    </option>
                                    </#list>
                                </select>
                                <input value="${(entity.fdaName)!}" type="hidden" id="fdaName" name="fdaName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">组成成分：</label>
                            <div class="col-sm-9">
                                <textarea id="component" name="component" class="form-control"
                                          placeholder="请输入组成成分" required>${(entity.component)!}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">适应症：</label>
                            <div class="col-sm-9">
                                <textarea id="indication" name="indication" class="form-control"
                                          placeholder="请输入适应症" required>${(entity.indication)!}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">不良反应：</label>
                            <div class="col-sm-9">
                                <textarea id="adverseReaction" name="adverseReaction" class="form-control"
                                          placeholder="请输入不良反应" required>${(entity.adverseReaction)!}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">禁忌：</label>
                            <div class="col-sm-9">
                                <textarea id="contraindication" name="contraindication" class="form-control"
                                          placeholder="请输入禁忌" required>${(entity.contraindication)!}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">剂量：</label>
                            <div class="col-sm-9">
                                <textarea id="dosage" name="dosage" class="form-control"
                                          placeholder="请输入剂量" required>${(entity.dosage)!}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">注意事项：</label>
                            <div class="col-sm-9">
                                <textarea id="note" name="note" class="form-control"
                                          placeholder="请输入注意事项" required>${(entity.note)!}</textarea>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 通用js引入 -->
<script src="${request.contextPath}/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="${request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${request.contextPath}/plugins/select2/select2.full.min.js"></script>
<script src="${request.contextPath}/plugins/layer/layer.min.js"></script>
<script src="${request.contextPath}/plugins/laydate/laydate.js"></script>
<script src="${request.contextPath}/plugins/jquery-confirm/jquery-confirm.min.js"></script>
<script src="${request.contextPath}/plugins/validate/jquery.validate.min.js"></script>
<script src="${request.contextPath}/plugins/validate/messages_zh.min.js"></script>
<script src="${request.contextPath}/plugins/blockUI/jquery.blockUI.js"></script>
<script src="${request.contextPath}/plugins/tinymce/tinymce.min.js"></script>
<script src="${request.contextPath}/hadmin/js/content.js"></script>
<script src="${request.contextPath}/hadmin/js/common.js?v=0.9"></script>
<script>
    // select2 初始化
    $('.select2').select2({
        language: 'zh-CN'
    });
    $(".select2").change(function(){
        $(this).valid();
    });
    tinymce.init({
        selector: '#adverseReaction',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#contraindication',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#dosage',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#note',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    // 选择药品类别
    $("#typeId").on('change',function(){
        if(!$("#typeId").val()) {
            $("#typeName").val("");
        } else {
            var text = $("#typeId").select2('data')[0].text.trim();
            $("#typeName").val(text);
        }
    })
    // 选择药品等级
    $("#fdaId").on('change',function(){
        if(!$("#fdaId").val()) {
            $("#fdaName").val("");
        } else {
            var text = $("#fdaId").select2('data')[0].text.trim();
            $("#fdaName").val(text);
        }
    })
    // 提交保存
    function submitHandler() {
        $("#adverseReaction").val(tinyMCE.editors[0].getContent());
        $("#contraindication").val(tinyMCE.editors[1].getContent());
        $("#dosage").val(tinyMCE.editors[2].getContent());
        $("#note").val(tinyMCE.editors[3].getContent());
        if ($("#druginfoEditForm").validate().form()) {
            saveInfo('${request.contextPath}/knowledge/druginfo/doEdit', $('#druginfoEditForm').serialize());
        } else {
            $("html,body").animate({scrollTop:0},1000);
            layer.msg("输入数据错误");
        }
    }
</script>
</body>
</html>
